//https://www.nowcoder.com/practice/4b91205483694f449f94c179883c1fef?tpId=60&&tqId=29483&rp=1&ru=/activity/oj&qru=/ta/tsing-kaoyan/question-ranking

#include <stdio.h>
#include <stdlib.h>

//构建树节点结构体
typedef struct BTNode{
    char val;
    struct BTNode* left;
    struct BTNode* right;
}BTNode;

//基于前驱遍历构建二叉树
BTNode* creatTree(char* a, int* pi){
    if(a[(*pi)]=='#'){
        (*pi)++;
        return NULL;
    }

    BTNode* root=(BTNode*)malloc(sizeof(BTNode));
    root->val=a[(*pi)];
    (*pi)++;
    root->left=creatTree(a, pi);
    root->right=creatTree(a, pi);

    return root;
}

//中序遍历并输出二叉树
void midTreeOrder(BTNode* root){
    if(root==NULL){
        return;
    }

    midTreeOrder(root->left);
    printf("%c ",root->val);
    midTreeOrder(root->right);
}


int main() {
    char a[100];
    scanf("%s",a);

    int i=0;
    BTNode* ret = creatTree(a, &i);
    midTreeOrder(ret);
    
    return 0;
}